<?php
  include('../init.php');
  
  if(isset($_GET["aid"]) AND $_GET["aid"]!=''){
    $aid= $_GET["aid"];
    $pid = $db->queryUniqueValue('SELECT p_id FROM hs_product WHERE c_id='.$aid);
    if($pid==NULL OR $pid==''){
      $sql = "DELETE FROM hs_category WHERE c_id=$aid";
      $db->execute($sql);
      
      if(file_exists('../../images/products/category/'.$aid)){
        remove_dir('../../images/products/category/'.$aid);
      }
    }
  }

  header("Location:index.php");
?>